package com.ymttest.database.redis;

import java.util.Set;

import com.ymt.core.tool.Logger;
import com.ymt.database.RedisDriver;
import com.ymttest.utils.EnvSetup;

public class discountsWapper {
	public static RedisDriver rd;
	int groupid = 1;

	public discountsWapper() {
		rd = new RedisDriver("group" + 1,
				EnvSetup.getSystemUrl("sentinel"));
	}

	public static String getDiscountTime(int userId)
	{
		discountsWapper imw = new discountsWapper();
		String timeStr=rd.getValue("pd:tc:"+userId);
		System.out.println("11111111"+timeStr);
		return timeStr;
	}
	

	public static void setDiscountTime(int userId,String str) {
		discountsWapper imw = new discountsWapper();
		System.out.println("11111111"+rd.setValue("pd:tc:"+userId,str));
	
	}
  public static void delDiscountTime(int userId) {
	   discountsWapper imw = new discountsWapper();
	    rd.getJedis().del("pd:tc:"+userId);
	 }
	

	public static void main(String args[]) {

		discountsWapper imw = new discountsWapper();

		System.out.println("11111111"+rd.getValue("pd:tc:20231266"));
		rd.getJedis().del("pd:tc:20231266");
		System.out.println("11111111"+rd.getValue("pd:tc:20231266"));
		
//		getDiscountTime(20226434);
		//setDiscountTime();
//		System.out.print(imw.rd.getValue("pd:tc:13171"));
//		System.out.print(imw.rd.getValue("pd:tc:2018-07-21T16:29:29"));
	//	System.out.println("11111111"+rd.getValue("pd:tc:20231266"));
	//	System.out.println("11111111"+rd.getValue("pd:tc:20231266"));
//		
//		
	//	System.out.println(rd.getValue("pd:tc:20231266"));
		
		//{"ndt":"2018-07-26T17:28:39","et":"2018-07-09T22:28:39","did":174}
//		String str=getDiscountTime(93246);
//		System.out.println(str.lastIndexOf(":"));
//		System.out.println(str.substring(str.lastIndexOf(":")+1, str.length()-1));
		
//		 Logger.debug(imw.getLastMs(3383, 10));
//		// 在FromUserId%4哨兵namespace下增加key：IMCache:11:FromUserId:1
//		// 在ToUserId%4哨兵namespace下增加key：IMCache:11:ToUserId:1
//		 String unms = imw.getLastUnMs(288484);
//		 Logger.debug(unms);
//		// Logger.debug(last);
////		Logger.debug(imw.getCount(390572,3791815));
//		Set<String> set = imw.rd.keys("IMCache:11*");
//		for (String s : set) {
//			Logger.debug(s);
//		}
	}
}
